#include<iostream>
#include<string>
#include<cstdio>
#include"searcher.hpp"

const std::string input="data/raw_html/raw.txt";

int main()
{
    ns_searcher::Searcher *search=new ns_searcher::Searcher();
    search->InitSearcher(input);
    
    std::string query;
    std::string json_string;
    char buffer[1024];
    while(true)
    {
        std::cout<<"Please Enter Your Query ";
        fgets(buffer,sizeof(buffer)-1,stdin);//fgets 自动余留一位为\0
        buffer[strlen(buffer)-1]=0;
        query=buffer;//(不会隐式类型转换，但赋值或构造可以)C++ 不会自动将 char* 转换为 const std::string&
        search->Search(query,&json_string);

        std::cout<<json_string<<std::endl;
    }
    // std::cout<<"Please Enter word for search#"<<std::endl;
    // std::string word,out;
    // while(fgets(word,std::cin) != nullptr)
    // {
    //     search->Search(word,&out);

    // }

    return 0;
}